package handler

import (
	"github.com/gin-gonic/gin"
	"log"
	"shop/shop-api/api/reponse"
	"shop/shop-api/api/request"
	"shop/shop-api/config"
	__ "shop/shop-srv/handler/proto"
)

func Login(c *gin.Context) {
	req := request.User{}
	if c.ShouldBind(&req) != nil {
		reponse.Error(c, "绑定失败")
		return
	}
	r, err := config.ShopClient.Login(c, &__.LoginReq{
		Account:  req.Account,
		Password: req.Password,
	})
	if err != nil {
		log.Fatalf("could not greet: %v", err)
	}
	reponse.Success(c, "登录成功", __.LoginResp{
		Id: r.Id,
	})
}
